<link href="__PUBLIC__/filer/jquery.filer.css" type="text/css" rel="stylesheet" />     

<form method="post" enctype="multipart/form-data" class="form-x one-form form-auto form-horizontal" id="form" action="{:U('/Case/runAdd',array('id'=>$case['id']))}">
	 <div class="panel one-box  active">
        <div class="panel-head">
			<if condition='ACTION_NAME eq "add"'>	
            <strong>添加作品</strong>
			<else/>
			<strong>添加作品</strong>
			</if>
        </div>
        <div class="panel-body">
          
            <div class="form-group">
                <div class="label">
                    <label>所属分类</label>
                </div>
                <div class="field">
                    <select class="input" name="class_id">
                        <?php if(!$case['class_id']):?>
                        <option value="">===请选择分类===</option>
                        <?php else:?>
                        <foreach name='caseSort' item='v'>
                            <?php if($case['class_id']==$v['id']):?>
                            <option value="{$v.id}">{$v.name}</option>
                            <?php endif;?>
                        </foreach>
                        <?php endif;?>
                        <foreach name='caseSort' item='v'>
                            <option value="{$v.id}">{$v.name}</option>
                        </foreach>
                    </select>
                </div>
            </div>
          
            <div class="form-group">
                <div class="label">
                    <label>标题</label>
                </div>
                <div class="field">
                    <input type="text" class="input" name="title" size="60" value="{$case.title}">
                    <div class="input-note">信息标题</div>
                </div>
            </div>
			 <div class="form-group">
                <div class="label">
                    <label>作者</label>
                </div>
                <div class="field">
                    <input type="text" class="input" name="editor" size="60" value="{$case.editor}">
                    <div class="input-note">信息标题</div>
                </div>
            </div>
			  <div class="form-group">
                <div class="label">
                    <label>书体</label>
                </div>
                <div class="field">
                    <input type="text" class="input" name="shuti" size="60" value="{$case.shuti}">
                    <div class="input-note">作品的书体</div>
                </div>
            </div>
			  <div class="form-group">
                <div class="label">
                    <label>规格</label>
                </div>
                <div class="field">
                    <input type="text" class="input" name="guige" size="60" value="{$case.guige}">
                    <div class="input-note">作品的规格</div>
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label>封面</label>
                </div>
                <div class="field">
                    <input type="text" class="input" id="image" name="image" readonly="readonly" size="38" value="{$case.image}">
                    <a class="button bg-blue button-small  js-img-upload" data="image" id="image_upload" preview="image_preview"><span class="icon-upload"> 上传</span></a>
                    <a class="button bg-blue button-small icon-picture-o" id="image_preview" href="javascript:;" > 预览</a>
                    <div class="input-note">封面图片尺寸360x309</div>
                </div>
            </div>
		<!-- 
            <div class="form-group">
                <div class="label">
                    <label>展示图片</label>
                </div>
                <div class="field">
                    <input type="file" name="files[]" id="demo-fileInput-7" multiple="multiple">
                    <div class="input-note">展示图片可多图上传，尺寸750x400</div>
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label>点击量</label>
                </div>
                <div class="field">
					<input type="text" class="input" name="xin" size="60" value="{$case.xin}">
                    <div class="input-note">点击量影响显示顺序，越高显示越靠前</div>
                </div>
            </div>
   -->
			<div class="form-group">
                <div class="label">
                    <label>详细内容</label>
                </div>
                <div class="field">
					<textarea type="input js-editor" class="input" name="content" style="width: 100%; height: 200px;" >{$case.content}</textarea>
                    <div class="input-note">所有图片宽度：750px,高度不限</div>
                </div>
            </div>
        </div>
        <div class="panel-foot">
            <div class="form-button">
                <div id="tips"></div>
                <input type="hidden" id="lunbo" name="lunbo" value="" />
				<button class="button bg-main" id="ajaxForm" type='submit'>保存</button>
				<if condition='ACTION_NAME eq "addCase"'>	
                <button class="button bg" type="reset">重置</button>
				</if>
            </div>
        </div>
    </div>
</form>
<script>
    KindEditor.ready(function(K) {
        var editor1 = K.create('textarea[name="content"]', {
            cssPath : '__PUBLIC__/keditor/plugins/code/prettify.css',
            uploadJson : '__PUBLIC__/keditor/php/upload_json.php',
            fileManagerJson : '__PUBLIC__/keditor/php/file_manager_json.php',
            allowFileManager : true
        });
        prettyPrint();
    });
    
    /*$("[name=type] option").each(function(){
    	$(this).click(function(){
    		alert(1);
        	query();
    	});
    	
    });*/
    
  //所属行业级联查询
    var cur = "http://"+window.location.hostname+"/";
    function query()
    {
    	$.ajax({
    		type : "POST",
    		url : "__ROOT__/admin.php/Case/selCaseType",
    		dataType : "json",
    		cache: false,
    		data: {caseType:$("[name=type] option:selected").prop("id")},
    		//contentType:"application/json;charset=utf-8",
    		error : function(data) {
    			layer.msg(data.info);
    		},
    		success : function(data) {
    			if (data.status == 1) {
    				$("[name=type_son]").empty();
    				$("[name=type_son]").append("<option value=''>===请选择所属行业===</option>");
    				$.each(data.list, function(index, objVal){
                        $("[name=type_son]").append("<option value='"+objVal['name']+"'>"+objVal['name']+"</option>");
    				});
                } 
    			else if(data.status == 2){
    				$("[name=type_son]").empty();
    				$("[name=type_son]").append("<option value=''>===该行业无二级分类===</option>");
    			}else {
                    layer.msg(data.info);
                }
    		},
    	});
    }
    
    //所属地区级联查询
    function query2()
    {
    	$.ajax({
    		type : "POST",
    		url : "__ROOT__/admin.php/Case/selCaseDiqu",
    		dataType : "json",
    		cache: false,
    		data: {caseDiqu:$("[name=diqu] option:selected").prop("id")},
    		//contentType:"application/json;charset=utf-8",
    		error : function(data) {
    			layer.msg(data.info);
    		},
    		success : function(data) {
    			if (data.status == 1) {
    				$("[name=diqu_son]").empty();
    				$("[name=diqu_son]").append("<option value=''>===请选择所属区域===</option>");
    				$.each(data.list, function(index, objVal){
                        $("[name=diqu_son]").append("<option value='"+objVal['name']+"'>"+objVal['name']+"</option>");
    				});
                } 
    			else if(data.status == 2){
    				$("[name=diqu_son]").empty();
    				$("[name=diqu_son]").append("<option value=''>===该区域无二级分类===</option>");
    			}else {
                    layer.msg(data.info);
                }
    		},
    	});
    }
    
    $(document).ready(function() {
    	
    	
    	
        $('#demo-fileInput-7').filer({
           showThumbs: true,
           <?php if ($photo != "") { ?>
           files: [
               <?php echo $photo ?>
           ],
           <?php } ?>
           extensions: new Array("jpg","gif","png"),
           templates: {
               box: '<ul class="jFiler-items-list jFiler-items-grid"></ul>',
               item: '<li class="jFiler-item">\
                           <div class="jFiler-item-container">\
                               <div class="jFiler-item-inner">\
                                   <div class="jFiler-item-thumb">\
                                       <div class="jFiler-item-status"></div>\
                                       <div class="jFiler-item-info">\
                                           <span class="jFiler-item-title"><b title="{{fi-name}}">{{fi-name | limitTo: 25}}</b></span>\
                                           <span class="jFiler-item-others">{{fi-size2}}</span>\
                                       </div>\
                                       {{fi-image}}\
                                   </div>\
                                   <div class="jFiler-item-assets jFiler-row">\
                                       <ul class="list-inline pull-left">\
                                           <li>{{fi-progressBar}}</li>\
                                       </ul>\
                                       <ul class="list-inline pull-right">\
                                           <li><a class="icon-jfi-trash jFiler-item-trash-action"></a></li>\
                                       </ul>\
                                   </div>\
                               </div>\
                           </div>\
                       </li>',
               itemAppend: '<li class="jFiler-item">\
                               <div class="jFiler-item-container">\
                                   <div class="jFiler-item-inner">\
                                       <div class="jFiler-item-thumb">\
                                           <div class="jFiler-item-status"></div>\
                                           <div class="jFiler-item-info">\
                                               <span class="jFiler-item-title"><b title="{{fi-name}}">{{fi-name | limitTo: 25}}</b></span>\
                                               <span class="jFiler-item-others">{{fi-size2}}</span>\
                                           </div>\
                                           {{fi-image}}\
                                       </div>\
                                       <div class="jFiler-item-assets jFiler-row">\
                                           <ul class="list-inline pull-left">\
                                               <li><span class="jFiler-item-others">{{fi-icon}}</span></li>\
                                           </ul>\
                                           <ul class="list-inline pull-right">\
                                               <li><a class="icon-jfi-trash jFiler-item-trash-action"></a></li>\
                                           </ul>\
                                       </div>\
                                   </div>\
                               </div>\
                           </li>',
               progressBar: '<div class="bar"></div>',
               itemAppendToEnd: false,
               removeConfirmation: true,
               _selectors: {
                   list: '.jFiler-items-list',
                   item: '.jFiler-item',
                   progressBar: '.bar',
                   remove: '.jFiler-item-trash-action'
               }
           },
           uploadFile: {
               url: "__ROOT__/Admin/Service/upload.php",
               data: 'json',
               type: 'POST',
               enctype: 'multipart/form-data',
               beforeSend: function(){},
               success: function(data, el){
                   var lunbo = $('#lunbo').val();
                   ajaxobj = eval("("+data+")");   // 解析json
                   lunbo += ajaxobj['metas'][0]['name'] + ","; // 给上传图片加逗号分割
                   $('#lunbo').val(lunbo); // 写入隐藏框中方便保存到数据库中
                   // 上传成功后重名明的图片名称，方便后续删除图片
                   el.find('.jFiler-item-title').html('<b title="'+ajaxobj['metas'][0]['name']+'">'+ajaxobj['metas'][0]['name']+'</b>');
                   var parent = el.find(".jFiler-jProgressBar").parent();
                   el.find(".jFiler-jProgressBar").fadeOut("slow", function(){
                       $("<div class=\"jFiler-item-others text-success\"><i class=\"icon-jfi-check-circle\"></i> 上传成功</div>").hide().appendTo(parent).fadeIn("slow");    
                   });
               },
               error: function(el){
                   var parent = el.find(".jFiler-jProgressBar").parent();
                   el.find(".jFiler-jProgressBar").fadeOut("slow", function(){
                       $("<div class=\"jFiler-item-others text-error\"><i class=\"icon-jfi-minus-circle\"></i> 上传失败</div>").hide().appendTo(parent).fadeIn("slow");    
                   });
               },
               statusCode: null,
               onProgress: null,
               onComplete: null
           },
           onRemove: function(itemEl, file){
               // 获取上传成功后的名称
               var file = itemEl.find('.jFiler-item-title b').attr('title');
               // JS执行删除图片操作
               $.post('__ROOT__/Admin/Service/remove_file.php', {file: file});
               // 修改操作
               <?php if ($photo != null) { ?>
                   var str = '{$travel.photo}';
                   var pattern = file + ",";
                   str = str.replace(new RegExp(pattern), "");
                   $('#lunbo').val(str);
                   $.post('__ROOT__/admin.php/Case/RemoveUpluad',{id:{$case.id},file:file});
               <?php } else { ?>   // 添加操作
                   var str = $('#lunbo').val();
                   var pattern = file + ",";
                   str = str.replace(new RegExp(pattern), "");
                   $('#lunbo').val(str);
               <?php } ?>
           }
       });
   });
</script>
<!-- 单图上传 -->
<script src="__PUBLIC__/webuploader/FileUpload.js"></script>
<!-- 多图上传 -->
<script src="__PUBLIC__/filer/jquery.filer.js"></script>